<?php
/**
 * Created by PhpStorm.
 * User: xshaitt
 * Date: 2016/8/2
 * Time: 14:45
 */
//计算出参数时间在当前时间多久以前
function timeToAgo($t)
{
    $diff = time()-$t;
    if($diff<=0)
    {
        return '未来';
    }
    $unit = array(array(946080000,'年'),array(2592000,'月'),array(86400,'天'),array(3600,'小时'),array(60,'分钟'));
    foreach ($unit as $v)
    {
        if($diff>=$v[0])
        {
            return floor($diff/$v[0]).$v[1];
        }
    }
    return $diff.'秒';
}
function sendMail($FromName,$to,$Subject,$Body)
{
    $mail = new PHPMailer(true);
    $mail->IsSMTP();
    $mail->CharSet='UTF-8';
    $mail->SMTPAuth = true;
    $mail->Port = 25;
    $mail->Host = "smtp.163.com";//邮箱smtp地址，此处以163为例
    $mail->Username = "xttaish@163.com";//你的邮箱账号
    $mail->Password = "x123456";//你的邮箱密码
    $mail->From = "xttaish@163.com";//你的邮箱账号
    $mail->FromName = $FromName;//你的邮箱账号
    $mail->AddAddress($to);
    $mail->Subject = $Subject;//主题
    $mail->Body = $Body;//正文
    $mail->WordWrap = 80;
    $mail->IsHTML(true);
    return $mail->Send();
}